﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DP.RecallDeal.Interface.ObjectTransformer

{
    /// <summary>
    /// Set values of T's properties to U's properties base on Mappings set.
    /// </summary>
    /// <typeparam name="T">Source object</typeparam>
    /// <typeparam name="U">Destination object</typeparam>
    public interface IObjectTransformerService
    {
        //IList<KeyValuePair<string, string>> Mappings { get; set; }

        IList<KeyValuePair<MappingMember, MappingMember>> Mappings { get; set; }

        IList<MappingException> MappingExceptions { get; }

        void TransformObject(object srcObj, object targetObject);

        /// <summary>
        /// This method is used to get value of an instance's property
        /// </summary>
        /// <param name="instance">Object instance</param>
        /// <param name="propertiesChain">Property which value will be taken. Would be able to have the form of "Parent.Child.GrandChild"</param>
        /// <returns>Desirable value</returns>
        object GetValueFromField(object instance, string propertiesChain, bool caseSensitive);
        object GetValueFromProperty(object instance, string fieldsChain, bool caseSensitive);

        /// <summary>
        /// This method is used to fill value to object's property in the chain
        /// </summary>
        /// <param name="propertiesChain">Target property will be filled by value. Would be able to have the form of Parent.Child.GrandChild</param>
        /// <param name="targetInstance">Object instance</param>
        /// <param name="sourceValue">Desirable value will be filled to target instance's property</param>
        void FillObjectToProperty(string propertiesChain, object targetInstance, object sourceValue, bool caseSensitive);
        void FillObjectToField(string fieldsChain, object targetInstance, object sourceValue, bool caseSensitive);
    }
}
